home *** CD-ROM | disk | FTP | other *** search
/ Workbench Add-On / Workbench Add-On - Volume 1.iso / Gfx / Edit / TSMorph / src / rexx / PreAnim.TSM < prev    next >
Text File  |  1995-02-05  |  5KB  |  114 lines

  1. /* example Preview script file for TSMorph        */
  2. /* This example renders all frames as 16 colour   */
  3. /* grey scale images, with a resolution of ~128x64*/
  4. /* using the T: directory as a work directory     */
  5. /* and then displays the animation using VT       */
  6. /*                                                */
  7. /* Frame number is taken as how often to render   */
  8. /* frames, 1=every frame, 3=every third etc.      */
  9. /* $VER: PreAnim_TSM 3.1 (5.2.95)
  10.  */
  11.  
  12. /* get arguments                                  */
  13. parse arg Frame " " FileName
  14.  
  15. /* Frame    - current frame number                */
  16. /* FileName - Filename of points file             */
  17. /*                                                */
  18. /* current Settings have previously been saved in */
  19. /* 'T:TSMorph.prefs'                              */
  20.  
  21. /* make rexx the default command host             */
  22. address "REXX"
  23. /* add rexxsupport.library if not already present */
  24. /* (required for next()                           */
  25. if ~(show('L','rexxsupport.library')) then
  26.    call addlib('rexxsupport.library',0,-30,0)
  27. /* open input file                                */
  28. if open('infile',FileName,'r') then do
  29.    /* open output file                            */
  30.    if open('outfile','T:TSM.points','w') then do
  31.       /* read possible header                     */
  32.       line = readln('infile')
  33.       /* write header                             */
  34.       call writeln('outfile','TSMorph 1.2')
  35.       if (line = 'TSMorph 1.2') then
  36.          /* read over header                      */
  37.          line = readln('infile')
  38.       /* read and write input file names          */
  39.       call writeln('outfile',line)
  40.       call writeln('outfile',readln('infile'))
  41.       call writeln('outfile',readln('infile'))
  42.       call writeln('outfile',readln('infile'))
  43.       /* read output name                         */
  44.       call readln('infile')
  45.       /* write our output file name               */
  46.       call writeln('outfile','T:TSM.pic.%03ld')
  47.       /* read and write details                   */
  48.       line = readln('infile')
  49.       parse var line "w=" width ",h=" height ",Frames=" frames ",Single=" single ",Start=" start
  50.       call writeln('outfile',line)
  51.       /* copy rest of file                        */
  52.       do while ~(eof('infile'))
  53.          call writeln('outfile',readln('infile'))
  54.       end
  55.       /* close output file                        */
  56.       call close('outfile')
  57.       /* calculate dx and dy parameters           */
  58.       /* image is then 128x64 minimum resolution  */
  59.       if (width > 128) then
  60.          dx = trunc((width - 128) / 128)
  61.       else
  62.          dx = 0
  63.       if (height > 64) then
  64.          dy = trunc((height - 64) / 64)
  65.       else
  66.          dy = 0
  67.       /* copy points for anim warps/morphs        */
  68.       if (single = 2) | (single = 3) then
  69.          if (Frame < 10) then
  70.             address command 'copy "'FileName'.00'Frame'" T:TSM.points.00'Frame
  71.          else
  72.             if (Frame < 100) then
  73.                address command 'copy "'FileName'.0'Frame'" T:TSM.points.0'Frame
  74.             else
  75.                address command 'copy "'FileName'.'Frame'" T:TSM.points.'Frame
  76.       /* Write Prescript                          */
  77.       /* This only renders the requested frames   */
  78.       if open('pre','T:Prescript.TSM','w') then do
  79.          /* Heading comment                       */
  80.          call writeln('pre','/* Preview Prescript */')
  81.          /* get arguments                         */
  82.          call writeln('pre','parse arg Base')
  83.          /* get frame number, from 1              */
  84.          /* see Prescript.TSM for more info       */
  85.          call writeln('pre','f = C2D(IMPORT(D2C(STRIP(Base),4),4),4)')
  86.          /* get total frames                      */
  87.          call writeln('pre','t = C2D(IMPORT(D2C(STRIP(Base)+4,4),4),4)')
  88.          /* Assume frames are 1..n                */
  89.          /* if it is not one of our frames then   */
  90.          call writeln('pre','if (f~=0) & (f~=t+1) & (trunc(f/'Frame')*'Frame'~=f) then')
  91.          /* do not produce this frame             */
  92.          /* see Prescript.TSM for more info       */
  93.          call writeln('pre','   call EXPORT(D2C(STRIP(Base)+40,4),D2C(0,4),4)')
  94.          /* Otherwise produce this frame          */
  95.          call writeln('pre','else')
  96.          call writeln('pre','   call EXPORT(D2C(STRIP(Base)+40,4),D2C(1,4),4)')
  97.          /* stop                                  */
  98.          call writeln('pre','exit')
  99.          /* close prescript file                  */
  100.          call close('pre')
  101.          /* call TSMorph-render to render frames  */
  102.          /* this saves BW16 Animation             */
  103.          /* Uses MODE=16 for speed                */
  104.          address command 'TSMorph:TSMorph-render INTEGER=YES FILES=T:TSM.points PRESCRIPT=T:Prescript POSTSCRIPT=Rexx/PostAnim CREATEICONSR=NO ANTIALIAS=NO DX='dx' DY='dy' SAVEFORMAT=BW16 MODE=16 SETTINGS=T:TSMorph.prefs'
  105.          /* Display the output                    */
  106.          address command "VT t:TSM_Anim"
  107.       end
  108.    end
  109.    /* close input file                            */
  110.    call close('infile')
  111. end
  112. /* the end!                                       */
  113. exit
  114.